package com.ghc.service.impl;

import com.ghc.service.IMessageProduct;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.messaging.Source;
import org.springframework.messaging.support.MessageBuilder;

//Source.class里边就是对通道的定义 （这是spring cloud stream内置的通道）
@EnableBinding(Source.class)
public class MessageProductImpl implements IMessageProduct {


    //
    @Autowired
    private Source source;


    @Override
    public void sendMessage(String massage) {
        //向mq中发送消息。操作stream
        //  使用通道向外发出消息
        source.output().send(MessageBuilder.withPayload(massage).build());
    }
}
